<template>
</template>

<script>
</script>

<style>
</style>
<template>
	<view class="send-goods">
		<u-form :model="form" ref="uForm" label-width="150rpx">
			<u-form-item label="快递配送"><u-input v-model="form.courierName" type="select" placeholder="请选择物流公司" @click="actionSheetShow = true"/></u-form-item>
			<u-form-item label="物流单号:"><u-input v-model="form.courierNo" type="text" placeholder="请输入物流单号" /></u-form-item>
			<u-button style="margin: 300rpx 50rpx 0 50rpx;" type="primary" shape="circle" @click="submit">确定发货</u-button>
		</u-form>
		<u-select v-model="actionSheetShow" :list="actionSheetList" @confirm="changeCourierName"></u-select>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				actionSheetShow: false,
				form: {
					courierName: '',
					courierNo: '',
					id: ''
				},
				uForm: {},
				actionSheetList:  [{
					value: '0',
					label: '顺丰速运'
				}, {
					value: '1',
					label: '中国邮政'
				}, {
					value: '2',
					label: '圆通速递'
				}, {
					value: '3',
					label: '中通快递'
				}, {
					value: '4',
					label: '申通快递'
				}, {
					value: '5',
					label: '宅急送'
				}, {
					value: '6',
					label: '联邦物流'
				}, {
					value: '7',
					label: '韵达快递'
				}, {
					value: '8',
					label: '京东快递'
				}, {
					value: '9',
					label: '百世快递'
				}, {
					value: '10',
					label: '其他快递'
				}],
				curOption: {}
			}
		},
		onLoad(option) {
			this.form.id = option.id;
		},
		methods: {
			changeCourierName(e) {
				this.curOption = e[0]
				this.form.courierName = e[0].label;
			},
			submit() {
				if (!this.form.courierName || !this.form.courierNo) {
					uni.showToast({
						icon:'none',
						title: '请确认物流信息填写完整？'
					});
					return false
				}
				this.$u.api.postMallOrderDeliver({
					courierName: this.curOption.value,
					courierNo: this.form.courierNo,
					id: this.form.id
				}).then(res=>{
					if(res.code == 0){
						uni.showToast({
							icon:'none',
							title: '发货成功'
						});
					}else{
						uni.showToast({
							icon:'none',
							title: res.msg
						});
					}
				})
			}
		}
	}
</script>

<style scoped>
.send-goods {
	padding: 0 30rpx;
}
</style>
